package logic

import (
	"context"
	"lucky/cache"

	"lucky/luckyrpc/internal/svc"
	"lucky/luckyrpc/luckyrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartClearLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCartClearLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartClearLogic {
	return &CartClearLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CartClearLogic) CartClear(in *luckyrpc.CartClearRequest) (*luckyrpc.CartClearResponse, error) {
	// todo: add your logic here and delete this line

	cache.Clear(int(in.UserId))

	return &luckyrpc.CartClearResponse{
		Success: true,
		Message: "购物车清除成功",
	}, nil
}
